package edu.qd.learn.newchapter.chapter02;

/**
 * @author 布衣
 */
public class Person {

    String name;
//    Animals  可以是接口，传递的实参，实现类的实例
    public void pet(Animals a){
        System.out.println(name+"这是我的宠物叫==>"+a);
    }


    public static void main(String[] args) {
        Person p = new Person();
        p.name = "康加修";
        //  多态
        Dog d1 = new Dog();
        p.pet(d1);
        d1.happy();

        Cat c1 = new Cat();
        p.pet(c1);
        c1.happy();

        p.pet(new Animals() {
            @Override
            public void happy() {
                System.out.println("Zzz...");
            }
        });
    }

}
